package com.project.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.ProjectBean;
import com.project.mapper.IProjectMapper;
import com.project.service.IProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class ProjectServiceImpl implements IProjectService {
    public int PAGESIZE = 3;
    @Autowired
    private IProjectMapper mapper;

    @Override
    public void add(ProjectBean project) {
        mapper.add(project);
    }

    @Override
    public ProjectBean findById(int id) {
        ProjectBean project = mapper.findById(id);
        return project;
    }

    @Override
    public PageInfo<ProjectBean> findByItem(int pageNO, String projectName, String state, String sort) {
        PageHelper.startPage(pageNO,PAGESIZE);
        PageInfo<ProjectBean> pageInfo = PageInfo.of(mapper.findByItem(projectName,state,sort));
        return pageInfo;
    }

    @Override
    public List<ProjectBean> findNoFinish() {
        List<ProjectBean> list = mapper.findNoFinish();
        return list;
    }

    @Override
    public void updateProjectState(int id) {
        mapper.updateProjectState(id);
    }
}
